<%@ Page Language="VB" StylesheetTheme="default" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="RoleManager.aspx.vb" Inherits="Secure_WebAdmin_RoleManager" title="Role Manager" %>
<%@ Register Assembly="DotNetPM.Web.UI.WebControls" TagPrefix="cc" Namespace="DotNetPM.Web.UI.WebControls" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table id="Table1" border="0" cellpadding="2" cellspacing="2" width="100%">
        <tr>
            <td colspan="4">
                <strong><font size="2">ROLE MANAGER</font></strong></td>
            <td align="right" colspan="1">
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Default.aspx" ForeColor="Blue">Back</asp:HyperLink></td>
        </tr>
        <tr style="color: #000000">
            <td colspan="5">
                <hr size="1" width="100%" />
            </td>
        </tr>
        <tr>
            <td rowspan="2" valign="top" width="15">
                &nbsp;</td>
            <td align="right" valign="bottom" style="height: 5px">
                <asp:LinkButton ID="lbutNew" runat="server" Font-Bold="True"><SPAN style="POSITION: relative; TOP: -4px; left:-4px">Add A New Question</SPAN><img src="../../Images/New.gif" style="border-width:0px;POSITION: relative;" /></asp:LinkButton></td>
            <td valign="top" style="height: 5px" width="100">
            </td>
            <td colspan="2" valign="top" style="height: 5px">
            </td>
        </tr>
        <tr>
            <td valign="top" height="400">
                <asp:GridView ID="gvRoles" runat="server" AutoGenerateColumns="False" DataSourceID="odsRoles" DataKeyNames="RoleName" Width="700px">
                    <Columns>
                        <asp:TemplateField HeaderText="RoleName" SortExpression="RoleName">
                            <ItemStyle Width="160px" />
                            <FooterStyle VerticalAlign="Top" BackColor="Beige" Width="160px" Wrap="False" />
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("RoleName") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtRoleName" runat="server" Text='<%# Bind("RoleName") %>' ValidationGroup="Adding" Width="90%" /><asp:RequiredFieldValidator
                                    ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtRoleName" Display="Dynamic"
                                    ErrorMessage="Role name is required." ValidationGroup="Adding">*<br />Role name is required.</asp:RequiredFieldValidator>
                            </FooterTemplate>
                            <EditItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("RoleName") %>'></asp:Label>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Description" SortExpression="Description">
                            <ItemStyle Width="400px" />
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <cc:countTextBox ID="txtDescription" runat="server" Text='<%# Bind("Description") %>' MaxLength="500" TextMode="MultiLine" Width="380px" />
                            </FooterTemplate>
                            <FooterStyle VerticalAlign="Top" BackColor="Beige" Width="400px" />
                            <EditItemTemplate>
                                <cc:countTextBox ID="txtDescription" runat="server" Text='<%# Bind("Description") %>' MaxLength="500" TextMode="MultiLine" Width="380px" />
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemStyle HorizontalAlign="Center" Width="40px" Wrap=False />
                            <FooterStyle HorizontalAlign=Center Width="40px" Wrap=False BackColor="Beige" />
                            <ItemTemplate>
                                <cc:dynImageButton ID="iButEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/images/edit_0.gif" tooltip="Edit Role" />
                                <cc:dynImageButton ID="iButDelete" runat="server" CommandName="Delete" ImageUrl="~/images/Delete_0.gif" 
                                    ToolTip="Delete Role" Visible='<%# IsDeletableRole(Eval("RoleName")) %>'
                                    OnClientClick="return confirm('Do you really want to delete this role?');" />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:ImageButton ID="iButUpdate" runat="server" CausesValidation="True" CommandName="Update" ImageUrl="~/images/ok.gif" tooltip="Update Role"/>
                                <asp:ImageButton ID="iButCancel" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/images/cancel.gif" tooltip="Cancel Changes"/>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:ImageButton ID="iButOk" runat="server" ImageUrl="~/images/ok.gif" OnClick="iButOk_Click" tooltip="Create Role"
                                    ValidationGroup="Adding" />
                                <asp:ImageButton ID="iButCancel" runat="server" CausesValidation="False" ImageUrl="~/images/cancel.gif" tooltip="Cancel"
                                    ValidationGroup="Adding" />
                            </FooterTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="#UsersInRole" SortExpression="NumberOfUsersInRole">
                            <ItemStyle HorizontalAlign="Center" Width="80px" />
                            <ItemTemplate>
                                <asp:LinkButton ID="lbUsersInRol" runat="server" Text='<%# Bind("NumberOfUsersInRole") %>'
                                    CommandName="Select"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:ObjectDataSource ID="odsRoles" runat="server" DeleteMethod="DeleteRole" InsertMethod="InsertRole" SelectMethod="GetRoles" TypeName="DotNetPM.Business.MembershipsAndRoles.RoleODS" UpdateMethod="UpdateRole">
                    <DeleteParameters>
                        <asp:Parameter Name="roleName" Type="String" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="roleName" Type="String" />
                        <asp:Parameter Name="desc" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="roleName" Type="String" />
                        <asp:Parameter Name="description" Type="String" />
                        <asp:Parameter Name="NumberOfUsersInRole" Type="Int32" />
                    </UpdateParameters>
                </asp:ObjectDataSource>
                &nbsp;
                </td>
            <td valign="top">
                <asp:GridView ID="gvUsersInRole" runat="server" DataSourceID="odsUsersInRole" AutoGenerateColumns="False">
                    <Columns>
                        <asp:ButtonField DataTextField="UsersInRole" HeaderText="UsersInRole" SortExpression="UsersInRole" CommandName="UserDetail"/>
                    </Columns>
                </asp:GridView>
                <asp:ObjectDataSource ID="odsUsersInRole" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="GetUsersInRole" TypeName="DotNetPM.Business.MembershipsAndRoles.RoleODS">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="gvRoles" Name="roleName" PropertyName="SelectedValue"
                            Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
            <td colspan="2" valign="top">
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>

